<?php 
header("Content-Type: text/javascript");
include("../../../appg/settings.php");
include("../../../appg/init_vanilla.php");
global $Context; 
?>
$(document).ready(function() { 
    $("form#frmPostDiscussion").before('<div class="ErrorContainer"><div class="ErrorTitle"><?=$Context->GetDefinition('VcalErrorTitle') ?></div><div class="Error"><?=$Context->GetDefinition('VcalApproved') ?></div></div>');
    $("input#StartDate").datepicker({beforeShow: customRange, dateFormat: '<?=$Context->Configuration['VCAL_DATEPICKER_FORMAT'] ?>', showOn: "button", buttonImage: "extensions/Vcal/theme/calendar.png", buttonImageOnly: true});
    $("input#EndDate").datepicker({beforeShow: customRange,dateFormat: '<?=$Context->Configuration['VCAL_DATEPICKER_FORMAT'] ?>', showOn: "button", buttonImage: "extensions/Vcal/theme/calendar.png", buttonImageOnly: true});
    $("#eventEditRepeatEnd").datepicker({maxDate: ($.datepicker.getDateFor('#eventEditRepeatEnd')), dateFormat: '<?=$Context->Configuration['VCAL_DATEPICKER_FORMAT'] ?>',showOn: "button", buttonImage: "extensions/Vcal/theme/calendar.png", buttonImageOnly: true});
    function customRange(input) {
	return {minDate: (input.id == 'EndDate' ? $.datepicker.getDateFor('#StartDate') : null),
		maxDate: (input.id == 'StartDate' ? $.datepicker.getDateFor('#EndDate') : null)};
    }

    $("ul#Repeat input:radio").bind('click', function(){
        var radioValue = $(this).attr('value');
        $("li.RepeatTypeOptions  p").each(function(){
            if ($(this).hasClass(radioValue)){
                $(this).show();
            } else {
                $(this).hide();
            }
        });

    });
    $("a#RepeatShowOptions").click(function () {
        $("ul#Repeat").show();
        return false;
    });
    $("a#AdvancedShowOptions").click(function () {
        $("ul.AdvancedOptions").show();
        return false;
    });
    $("a#SkipShowOptions").click(function () {
        $("#RepeatTypeSkip span").show();
        return false;
    });
    $("input#AllDayEvent").click(function () {
        if (this.checked) {
            $("li.Time").hide().slow();
        } else {
            $("li.Time").show().slow();
        }    
    });

});

